Strymmap Example

Apart from CAN bus data, comma.ai’s grey panda and black panda devices also record GPS data. strymmap enables to read the GPS data from such recording and make interesting observation.

[3]:
import strym
from strym import strymmap
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
Loading BokehJS ...

Using Mapbox

Let’s set up API Key for Mapbox. If you don’t know how to generate API Key for MAP Box, please look at the video: https://www.youtube.com/watch?v=6iQEhaE1bCY. Note that this is one-time step and need be repeated if you have done earlier.

[ ]:
api_key = input("Enter API Key: ")
[2]:
!echo "export MAP_BOX_API={api_key}" >> ~/.env

By default map size has width 1200px, height 800 px and zoom level of 12 but they can be changed as follows:

[4]:
strym.config["mapheight"] = 700
strym.config["mapwidth"] = 1250
strym.config["mapzoom"] = 12.20

Instantiating strymmap will read GPS CSV file and create save the drive route on map as a png and html file in the location where GPS csvfile exists.

[5]:
datafolder='../PandaData/2020_03_12/'
file = '2020-03-12-10-56-10_GPS_Messages.csv'
g = strymmap(csvfile=datafolder+file)
g.dataframe = g.dataframe.dropna()
GPS signal first acquired at 2020-03-12 17:56:20:600000

We can also load the map on the notebook. For static map, pass interactive=True

[6]:
fig = g.plotroute(interactive=True)

Using Google Map

Similarly, you can use Google map for plotting as follows

You will ensure that you have right Google API KEY before you can use strymmap. You can generate API KEY at https://console.developers.google.com/projectselector2/apis/dashboard.

[ ]:
google_api_key = input("Enter Google MAP API Key: ")
[ ]:
!echo "GOOGLE_MAP_API_KEY={google_api_key}" >> ~/.env

After setting Google map api key, you need to tell strymmap to use Google Map. By default, strymmap uses Map box since version 0.3.6

[7]:
strym.config["map"] = "googlemap"
[8]:
g = strymmap(csvfile=datafolder+file)
g.dataframe = g.dataframe.dropna()
fig = g.plotroute(interactive=True)
GPS signal first acquired at 2020-03-12 17:56:20:600000

Looking for [chromedriver 86.0.4240.22 linux64] driver in cache
File found in cache by path [/home/ivory/.wdm/drivers/chromedriver/86.0.4240.22/linux64/chromedriver]
Loading BokehJS ...
Loading BokehJS ...

We can create such maps for all drive for which we have GPS recording

[ ]:
import glob
parentfolder = '../../PandaData/'
folderlist = glob.glob(parentfolder+"*")
csvlist = []
for datafolder in folderlist:
    csvlisttmp = glob.glob(datafolder+"/*.csv")
    for f in csvlisttmp:
        csvlist.append(f)

for index, f in enumerate(csvlist):
    if 'GPS' in f:
        print('{}. File currently being read is {}'.format(index, f))
        g = strymmap(csvfile=f)
        try:
            g.dataframe = g.dataframe.dropna()
        except AttributeError:
            pass
        print('\n')